<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 求一组数中的最大值和最小值，以及所在位置的下标。 -->


    <script type="text/javascript">
        var arr = [20, 22, 58, 16, 89, 4, 12, 5, 88, 90, 117, 34, 67]
        var min = arr[0];
        var max = arr[0]
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] < min) {
                min = arr[i]
            }
            if (arr[i] > max) {
                max = arr[i]
            }
        }
        var minIndex = arr.indexOf(min)
        var maxIndex = arr.indexOf(max)
        console.log("该数组的最小数为:" + min, "该下标位置在" + minIndex);
        console.log("该数组的最大数为:" + max, "该下标位置在" + maxIndex);
    </script>
</body>

</html>